package com.example.myapplication;

import android.os.Bundle;
import android.util.Log;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import xyz.doikki.videocontroller.StandardVideoController;
import xyz.doikki.videoplayer.player.VideoView;

public class VideoPlayActivity extends AppCompatActivity {

    private VideoView mVideoView;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_video_paly);
        mVideoView = findViewById(R.id.mVideoView);
        String url = getIntent().getStringExtra("video_url");
        String name = getIntent().getStringExtra("video_name");
        //视频控制器
        StandardVideoController standardVideoController = new StandardVideoController(this);
        VideoControlView videoControlView = new VideoControlView(this);
        standardVideoController.addControlComponent(videoControlView);
        videoControlView.setTitle(name);
        mVideoView.setVideoController(standardVideoController);
        Log.d("TAG", "onCreate: " + url);
        mVideoView.setUrl(url);
        mVideoView.start();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mVideoView.release();
    }
}
